package com.runda.task;

import java.io.InputStream;
import com.aliyun.oss.OSSClient;

/**
 * 阿里云oss  文件流上传
 * @author Administrator
 *
 */
public class AliyunOssUploadFromInputStream extends Thread {
	private String endpoint;
	private String accessKeyId;
	private String accessKeySecret;
	private String key;
	private String bucket;
	private InputStream inputStream;
	private String id;
	private String cdnpath;
	@Override
	public void run() {
		try {
		    // 创建OSSClient实例
		    OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
		    ossClient.putObject(bucket, key, inputStream);
		    // 关闭client
		    ossClient.shutdown();
		  /*  com.rundatop.biz.resource.domain.Resource resource = new com.rundatop.biz.resource.domain.Resource();
		    resource.setId(this.id);
		    resource.setPath(this.key);
		    resourceservice.updateResource(resource);*/
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	public AliyunOssUploadFromInputStream(String endpoint, String accessKeyId, String accessKeySecret, String key,
			String id, String bucket, String cdnpath, InputStream inputStream) {
		super();
		this.endpoint = endpoint;
		this.accessKeyId = accessKeyId;
		this.accessKeySecret = accessKeySecret;
		this.key = key;
		this.id = id;
		this.bucket = bucket;
		this.cdnpath = cdnpath;
		this.inputStream = inputStream;
	}
	
	
	
	
	

}
